home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-07-28 | 2.6 KB | 123 lines | [TEXT/MPS ] |
- /*
- File: DirectObject.cp
-
- Copyright: © 1991-1994 by Apple Computer, Inc.
- All rights reserved.
-
- Part of the AOCE Sample SMSAM Package. Consult the license
- which came with this software for your specific legal rights.
-
- */
-
-
-
- #ifndef __DIRECTOBJECT__
- #include "DirectObject.h"
- #endif
-
- #ifndef __DEBUGASSERT__
- #include "DebugAssert.h"
- #endif
-
- #ifndef __DEBUGGINGGEAR__
- #include "DebuggingGear.h"
- #endif
-
- #ifndef __IOSTREAM__
- #include "IOStream.h"
- #endif
-
- /***********************************|****************************************/
-
- ostream& operator << ( ostream& s, const TDirectObject* o )
- {
- if ( o )
- return *o >> s;
- else
- return s << "<NIL>";
- }
-
- /***********************************|****************************************/
-
- TDirectObject::TDirectObject ()
- {
- #if defined ( debug )
- fTag = kDirectObjectTag;
- #endif
- }
-
- /***********************************|****************************************/
-
- TDirectObject::TDirectObject ( const TDirectObject& )
- {
- #if defined ( debug )
- fTag = kDirectObjectTag;
- #endif
- }
-
- /***********************************|****************************************/
-
- TDirectObject::~TDirectObject ()
- {
- #if debug
- fTag = '\?\?\?\?';
- #endif
- }
-
- /***********************************|****************************************/
-
- TDirectObject&
- TDirectObject::operator = ( const TDirectObject& that )
- {
- ASSERT ( this != &that );
- return *this;
- }
-
- /***********************************|****************************************/
-
- ostream&
- TDirectObject::operator >> ( ostream& s ) const
- {
- s << "TDirectObject @ " << (void*) this;
- return s;
- }
-
- /***********************************|****************************************/
-
- Boolean TDirectObject::IsADirectObject ( const void * p )
- { TDirectObject * t = (TDirectObject *) p;
-
- return t->fTag == kDirectObjectTag;
- }
-
- /***********************************|****************************************/
-
- Boolean TDirectObject::IsValidObject ( Boolean mustReturn ) const
- {
- Ptr p = (Ptr) this;
-
- if ( ( (long) p & 0x00000001 ) || // If the object pointer is odd,
- ( p < (Ptr) & ( ApplicZone()->heapData ) ) || // or below the application zone
- ( p > ApplicZone()->bkLim ) ) // or above the application zone
- {
- keith << "TDirectObject::IsValidObject(), bad object pointer." << endl;
- }
- else if ( fTag != kDirectObjectTag )
- {
- keith << "TDirectObject::IsValidObject(), fTag != kDirectObjectTag." << endl;
- }
- else
- {
- return true;
- }
-
- // If we get here, the object is bad, so print out a stack crawl,
- // call Failure() for the current thread, and exit.
- if ( ! mustReturn )
- FAIL ( -1 );
-
- return false;
- }
-
- /***********************************|****************************************/
-